package cn.com.test.sso.shiro.realm;

import org.apache.shiro.authc.*;
import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.realm.AuthorizingRealm;
import org.apache.shiro.subject.PrincipalCollection;

public class MyRealm extends AuthorizingRealm {

	@Override
	protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) {
		return null;
	}

	@Override
	protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException {

		UsernamePasswordToken token = (UsernamePasswordToken) authenticationToken;

		if ("chenwb".equals(token.getUsername())) {
			return new SimpleAuthenticationInfo("chenwb", "chenwb", this.getName());
		}
		return null;
	}
}
